package com.swmaestro.twar.model;

import org.json.JSONArray;
import org.json.JSONException;

import android.util.Log;

import com.swmaestro.twar.Utils;

public class FeedList {
	public Feed[] list;
	
	public FeedList(JSONArray ja) throws JSONException {
		int num_of_entries = ja.length();
		this.list = new Feed[num_of_entries];
		
		for(int i=0; i<num_of_entries; i++) {
			Feed feed = new Feed(ja.getJSONObject(i));
			this.list[i] = feed;
		}
	}
	
	public static void log(String TAG, FeedList feedList) {
		if(feedList != null) {
			Log.e(TAG, "===========================");
			for(int i=0; i<feedList.list.length; i++) {
				Feed feed = feedList.list[i];
				Log.e(TAG, (i+1) + ". " + feed.name + " (" + Utils.convertDateTime2String(feed.date, true) + " )");
				Log.e(TAG, feed.content);
				Log.e(TAG, "(" + feed.num_of_ups + " / " + feed.num_of_downs + ")");
			}
			Log.e(TAG, "===========================");
		} else {
			Log.e(TAG, "FeedList is null!");
		}
	}
}
